

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import GLib, Gio, Gtk

import sys


#
# 1. our .glade file (may contain paths)
#
@Gtk.Template.from_file("test.glade")
class AppWindow(Gtk.ApplicationWindow):
    #
    # 2. the GtkApplicationWindow class
    #
    __gtype_name__ = "myapp_window"

    #
    # 3. the Button name we saved above
    #
    first_button: Gtk.Button = Gtk.Template.Child()

    #
    # 4. the signal handler name we saved above
    #
    @Gtk.Template.Callback()
    def first_button_clicked_cb(self, widget, **_kwargs):
        assert self.first_button == widget
        print(widget.get_label())


class Application(Gtk.Application):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, application_id="dev.monique.Gtk1",
                         flags=Gio.ApplicationFlags.FLAGS_NONE, **kwargs)
        self.window = None

    def do_activate(self):
        self.window = self.window or AppWindow(application=self)
        self.window.present()


if __name__ == '__main__':
    Application().run(sys.argv)



